

var table;
var $;
layui.use('table', function() {
    table=layui.table;
    table.on('radio(test)', function(obj){ //test 是 table 标签对应的 lay-filter 属性
        console.log(obj); //当前行的一些常用操作集合
        console.log(obj.checked); //当前是否选中状态
        console.log(obj.data); //选中行的相关数据
    });
})



layui.use('jquery', function() {
    $ = layui.jquery;
    $.ajax({
        url: "/Teacher/selectTable1",
        type: "get",
        dataType: "json",
        data: {},
        success: function (data) {
            console.log(data);
            $("input[name=course_name]").val(data.obj[0].course_name);
            $("input[name=create_date]").val(data.obj[0].create_date);
            $("input[name=create_user]").val(data.obj[0].create_user);
            $("input[name=course_nprice]").val(data.obj[0].course_nprice);
            $("input[name=course_primary]").val(data.obj[0].course_primary);
            $("input[name= categroy_name]").val(data.obj[0]. categroy_name);
            $("input[name= like_num]").val(data.obj[0]. like_num);
            $("input[name=collect_num]").val(data.obj[0].collect_num);
            $("input[name=content]").val(data.obj[0].content);
            $("input[name=course_intro]").val(data.obj[0].course_intro);
            $("input[name=remarks]").val(data.obj[0].remarks);
        }
    });
});
layui.use(['upload', 'element', 'layer'], function(){
    var $ = layui.jquery
        ,upload = layui.upload
        ,element = layui.element
        ,layer = layui.layer;
    var uploadInst = upload.render({
        elem : '#test3',
        url : '/Teacher/insertImg',
        done : function(res) {
            layer.msg('上传成功');
            console.log(res.image)
            $("#a").attr("src","http://127.0.0.1:8089"+res.image);
        },
        drag : true,
        accept : 'file',
        multiple : true,
    });
    upload.render({
        elem: '#test5'
        ,url: '/Teacher/insertVideo' //改成您自己的上传接口
        ,accept: 'video' //视频
        ,done: function(res){
            layer.msg('上传成功');
            console.log(res);
            $("#videoShow").attr("src","http://127.0.0.1:8089"+res.image);
        }
    });
});
$(function () {
    //视频
    jsModern.video("#video");
    //播放视频
    $(".VideoBtn").click(function () {
        var video = document.getElementById("videoShow");
        video.play();
        $('.VideoBtn').hide();
    })
    //监听视频的播放状态
    var video = document.getElementById("videoShow");
    video.oncanplay = function () {
        $(".VideoBtn").show();
        //$("#video").attr("poster","");
    }
    //视频播放事件
    video.onplay = function () {
        $("#videoShow").attr("poster", "");
        $(".VideoBtn").hide();
    };
    video.onplaying = function () {
        $(".VideoBtn").hide();
    };

    //视频暂停事件
    video.onpause = function () {
        $(".VideoBtn").show();
    };
    //点击视频周围暂停播放图片出现
    video.onclick = function () {
        if (video.paused) {
            $(".VideoBtn").hide();
            video.play();
        } else {
            $(".VideoBtn").show();
            video.pause();
        }
    };
})